package week3;

/**
 * Created by Administrator on 2016/3/19.
 */
class CashCard2 {
    String number;
    int balance;
    int bonus;
    CashCard2(String number,int balance,int bonus){
        this.number = number;
        this.balance = balance;
        this.bonus = bonus;
    }

    void store(int money){//储值时调用的方法
        if(money > 0){//封装储值流程
            this.balance += money;
            if(money >= 1000){
                this.bonus++;
            }
        }
        else {
            System.out.println("储值是负的？你是乱来的吗？");
        }
    }

    void charge(int money){
        if (money > 0){
            if (money <= this.balance){
                this.balance -= money;
            }
            else {
                System.out.println("钱不够啦！");
            }
        }
        else {
            System.out.println("扣负数？这不是叫我储值？");
        }
    }

    int exchange(int bonus){ //兑换红利点数时调用的方法 //会返回int型态
        if (bonus > 0){
            this.bonus -= bonus;
        }
        return this.bonus;
    }
}
